#include "system.h"
#include "bsp.h"
#include "drv_led.h"
#include "drv_beep.h"
#include "drv_key.h"
#include "drv_qspi_w25qxx.h"


/* BootLoader */

extern void boot_handle(void);


int main(void)
{
	int i;

    bsp_init();

    drv_led_init();
    drv_beep_init();
    drv_key_init();

    i = drv_qspi_w25qxx_init();
    if (i == 0)
    {
        drv_qspi_w25qxx_memory_mapped();
        boot_handle();
    }
    else
    {
        printf("QSPI W25QXX init fail\r\n");
    }

    printf("Code run in BoorLoader\r\n");
    while (1)
    {
        // printf("STM32H750\r\n");
        
        drv_led_led0_on();
        drv_led_led1_off();
        delay_ms(500);
        drv_led_led0_off();
        drv_led_led1_on();
        delay_ms(500);

        if (drv_key_pres_key0())
        {
            printf("key0 press\r\n");
        }
        if (drv_key_pres_key1())
        {
            printf("key1 press\r\n");
        }

    }
    
}
